package com.micro.school.system.api;

import com.micro.school.system.api.domain.vo.MerMerchantVos;
import com.micro.school.system.api.domain.StudentInfos;
import com.micro.school.system.api.domain.SysUser;
import com.micro.school.system.api.domain.vo.StudentInfoVos;
import com.micro.school.system.api.domain.vo.StudentPayVos;
import com.micro.school.system.api.factory.RemoteUserFallbackFactory;
import com.micro.school.system.api.model.LoginUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.micro.school.common.core.constant.SecurityConstants;
import com.micro.school.common.core.constant.ServiceNameConstants;
import com.micro.school.common.core.domain.R;

import java.util.List;

/**
 * 用户服务
 *
 * @author upupgo
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 记录用户登录IP地址和登录时间
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PutMapping("/user/recordlogin")
    public R<Boolean> recordUserLogin(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/info/queryStudent")
    public R<StudentInfos> queryStudent(@RequestBody StudentInfoVos studentInfoVos);


    @PostMapping(value = "/info/queryVosByIdNumber")
    R<List<StudentInfoVos>> queryVosByIdNumber(StudentInfoVos studentInfoVos);


    @GetMapping("/merMerchant/fegin/{ids}")
    public R<MerMerchantVos> queryMerMerchantById(@PathVariable("ids") Integer ids);

    @PostMapping("/info/list/limitById")
    public R<List<StudentInfos>> listStudentLimitById(@RequestBody StudentInfos studentInfoVo);

    /**
     *
     * 一次查询多个学生
     * */
    @PostMapping(value = "/info/queryStudentByIds")
    public R<List<StudentInfos>> queryStudentByIds(@RequestBody List<Long> ids);


    @GetMapping(value = "/merMerchant/queryMerchantById/{id}")
    public R<MerMerchantVos> queryMerchantById(@PathVariable("id") Long id);

    @PostMapping(value = "/pay/saveList")
    void insertStudentPayVos(@RequestBody List<StudentPayVos> data);

    @PostMapping(value = "/pay/updateList")
    void updateStudentPayVos(List<StudentPayVos> data);

    @PostMapping(value = "/schoolInfo/selectSchoolById")
    StudentInfoVos selectSchoolById(@RequestParam("id") Long id);

    @PostMapping(value = "/info/updateAllStudentInfoCollegeName")
    void updateAllStudentInfoCollegeName(@RequestParam("collegeName")String collegeName,@RequestParam("collegeId") Long collegeId,@RequestParam("oldCollegeName") String oldCollegeName);

    @PostMapping(value = "/info/updateAllCollegeMajor")
    void updateAllCollegeMajor(@RequestParam("majorName")String majorName,@RequestParam("id") Long id,@RequestParam("oldMajorName") String oldMajorName);

    @PostMapping(value = "/info/updateAllCollegeModel")
    void updateAllCollegeModel(@RequestParam("modelName")String modelName,@RequestParam("id") Long id,@RequestParam("oldModelName") String oldModelName);

    @PostMapping(value = "/info/updateAllCampusName")
    void updateAllCampusName(@RequestParam("campusName")String campusName,@RequestParam("id") Long id,@RequestParam("oldCampusName") String oldCampusName);

    @PostMapping(value = "/info/updateAllSchoolGrade")
    void updateAllSchoolGrade(@RequestParam("grade")String grade,@RequestParam("id") Long id);
}
